| Time | Content |
|---|---|
| 10:00–10:30 | Drawing plots with ggplot2 |
| 10:30–11:00 | Exercise 1 |
| 11:00–11:30 | The Grammar of Graphics |
| 11:30–12:00 | Exercise 2 |
| 12:00–12:10 | Break |
| 12:10–12:30 | Drawing multiple layers with ggplot2 |
| 12:30–12:50 | Exercise 3 |
| 12:50–13:00 | Wrap up |
ANU BDSI
workshop Data Visualisation with R Part 1
Biological Data Science Institute
10th April 2024
https://emitanaka.org @statsgen fosstodon.org/@emitanaka
All materials will be hosted at
https://anu-bdsi.github.io/workshop-data-vis-R1/
| Time | Content |
|---|---|
| 10:00–10:30 | Drawing plots with ggplot2 |
| 10:30–11:00 | Exercise 1 |
| 11:00–11:30 | The Grammar of Graphics |
| 11:30–12:00 | Exercise 2 |
| 12:00–12:10 | Break |
| 12:10–12:30 | Drawing multiple layers with ggplot2 |
| 12:30–12:50 | Exercise 3 |
| 12:50–13:00 | Wrap up |
ggplot2
ggplot2
ggplot2ggplot2
ggplot2
ggplot2
In linguistics, we combine finite number of words to construct vast number of sentences under a shared understanding of the grammar.
Wilkinson (2005) introduced “the grammar of graphics” as a paradigm to describe plots by combining a finite number of components.
Wickham (2010) interpreted the grammar of graphics into the ggplot2 R package (as part of his PhD project)
The grammar of graphics paradigm is also interpreted in other programming languages such as Python (e.g., plotnine), Julia (e.g., VegaLite.jl), and JavaScript (e.g., Vega).
y = stat(density) and y = ..density..
geom_bar()geom_col()geom_point()geom_tile()geom_density()geom_bar()stat = "count" is computing the frequencies for each category for you.stat_count() and change the geom.geom_col()stat = "count" to do the counting for you and use geom_col() instead.geom_bar(stat = "identity") where stat = "identity" means that you will take the value as supplied without any statistical transformation."stack""dodge""dodge" = position_dodge()"dodge2""dodge2" uses a different algorithm to recalculate the x-values with an option to add a padding between geometric objects"fill"x, then position = "fill" can be handy.coord_polar()coord_cartesian() for Cartesian coordinate systems (default)coord_flip() to flip the x and ycoord_fixed() to use a fixed aspect ratiocoord_equal() is essentially coord_fixed(ratio = 1)coord_trans() to transform the coordinate after the statistical transformationcoord_map() to use projection based on mapproj30:00 anu-bdsi.github.io/workshop-data-vis-R1/